<?php
/**
 * Memcached Client / Tokyo Tyrant test
 *
 * Please start tokyo tyrant by 'ttserver -dmn' for daemon mode)
 * before running this script from the command line.
 *
 * Test Results
 * ------------
 * 
 * Method: stress_test.php, fasttyrant class:
 * Task: 10K writing, 10K reading
 * 
 * Disk Table    (.tct): 3.40, 3.41
 *  
 * PHP version 5
 *
 * @category  PHP
 * @package   Tokyo_Tyrant
 * @author    Tamas Kalman <ktamas77@gmail.com>
 * @license   BSD
 */

error_reporting(E_ALL);
$max_stress = 10000;

require "../phptyrant.inc.php";
require "phptimer/timer.class.inc.php";

echo "Memcached Tyrant Stress Test ($max_stress)\n";

$timer = new Timer();

$tyrant = new MemCache(); // PHP optimized class

echo "Opening Tyrant...\n";
$tyrant->addServer("127.0.0.1", DEFAULT_PORT);

echo "Writing ($max_stress)...\n";

$timer->start("put");
for ($i=0;$i<$max_stress;$i++) {
	$testkey = "test_".$i;
	$testdata = "testdata_".$i;
	$tyrant->set($testkey, $testdata);
}
$timer->stop("put");

echo "Reading ($max_stress)...\n";

$timer->start("get");
for ($i=0;$i<$max_stress;$i++) {
	$testkey = "test_".$i;
	$testdata = "testdata_".$i;
	$var = $tyrant->get($testkey);
}
$timer->stop("get");

echo "Closing connection...\n";
$tyrant->close();

var_dump($timer->getAll());

echo "Done.\n";

?>